home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
tcl
/
tcl70b2.lha
/
tcl7.0b2
/
tests
/
cd.test
< prev
next >
Wrap
Text File
|
1993-07-08
|
4KB
|
120 lines
# Commands covered: cd, pwd
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands. Sourcing this file into Tcl runs the tests and
# generates output for errors. No output means no errors were found.
#
# Copyright (c) 1991-1993 The Regents of the University of California.
# All rights reserved.
#
# Permission is hereby granted, without written agreement and without
# license or royalty fees, to use, copy, modify, and distribute this
# software and its documentation for any purpose, provided that the
# above copyright notice and the following two paragraphs appear in
# all copies of this software.
#
# IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
# DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
# OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
# CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
# ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
# PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
# $Header: /user6/ouster/tcl/tests/RCS/cd.test,v 1.20 93/07/08 10:29:53 ouster Exp $ (Berkeley)
if {[string compare test [info procs test]] == 1} then {source defs}
catch {exec rm -rf cd.dir}
exec mkdir cd.dir
exec cat << "Sample text" > cd.dir/test.file
set cwd [exec pwd]
test cd-1.1 {simple pwd check} {
pwd
} $cwd
cd cd.dir
test cd-2.1 {changing directories} {
list [exec pwd]
} $cwd/cd.dir
test cd-2.2 {changing directories} {
pwd
} $cwd/cd.dir
test cd-2.3 {changing directories} {
exec cat test.file
} "Sample text"
cd ..
test cd-2.4 {changing directories} {
exec pwd
} $cwd
test cd-2.5 {changing directories} {
pwd
} $cwd
test cd-2.6 {changing directories} {
exec cat cd.dir/test.file
} "Sample text"
# The tests below seem to fail on lots of machines for a variety
# of reasons, such as the auto-mounter, home directories that are
# symbolic links, etc.
if $atBerkeley {
set home [exec sh -c "cd; pwd"]
test cd-2.7 {changing directories} {
cd ~
set x [list [exec pwd] [pwd]]
cd $cwd
set x
} "$home $home"
test cd-2.8 {changing directories} {
cd
set x [list [exec pwd] [pwd]]
cd $cwd
set x
} "$home $home"
}
test cd-3.1 {cd return value} {
cd .
} {}
test cd-4.1 {errors in cd command} {
list [catch {cd 1 2} msg] $msg $errorCode
} {1 {wrong # args: should be "cd dirName"} NONE}
test cd-4.2 {errors in cd command} {
string tolower [list [catch {cd _bad_dir} msg] $msg $errorCode]
} {1 {couldn't change working directory to "_bad_dir": no such file or directory} {posix enoent {no such file or directory}}}
test cd-4.3 {errors in cd command} {
string tolower [list [catch {cd cd.dir/test.file} msg] $msg $errorCode]
} {1 {couldn't change working directory to "cd.dir/test.file": not a directory} {posix enotdir {not a directory}}}
test cd-4.4 {errors in cd command} {
set home $env(HOME)
unset env(HOME)
set x [list [catch cd msg] $msg]
set env(HOME) $home
set x
} {1 {couldn't find HOME environment variable to expand "~"}}
test cd-5.1 {errors in pwd command} {
list [catch {pwd a} msg] $msg
} {1 {wrong # args: should be "pwd"}}
if $atBerkeley {
exec mkdir cd.dir/child
cd cd.dir/child
exec chmod 111 ..
if {$user != "root"} {
test cd-5.2 {errors in pwd command} {
catch pwd msg
} 1
}
cd $cwd
exec chmod 775 cd.dir
}
catch {exec rm -rf cd.dir}
format ""